package com.bawei.system.remote.factory;


import com.bawei.common.core.domain.R;
import com.bawei.system.domain.vo.EsDocInsertVo;
import com.bawei.system.domain.vo.EsDocQueryVo;
import com.bawei.system.remote.api.RemoteEsDocService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteEsDocFallbackFactory implements FallbackFactory<RemoteEsDocService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteEsIndexFallbackFactory.class);

    @Override
    public RemoteEsDocService create(Throwable throwable) {
        log.error("全文检索服务调用失败:{}", throwable.getMessage());
        return new RemoteEsDocService() {

            @Override
            public R<Boolean> batchInsertDocs(List<EsDocInsertVo> esDocInsertVo) {
                return R.ok(false, "插入失败，请稍后重试");
            }

            @Override
            public R queryDocs(EsDocQueryVo esDocInsertVo) {
                return R.ok(false, "查询失败，请稍后重试");
            }

            @Override
            public R<Boolean> deleteDocsById(String docsId) {
                return R.ok(false, "删除失败，请稍后重试");
            }

            @Override
            public R<Boolean> batchDeleteDocs(List<String> docsIds) {
                return R.ok(false, "删除失败，请稍后重试");
            }

            @Override
            public void querySuggestions(EsDocQueryVo esDocSelectVo) {
                R.ok(false,"查询失败,请稍后再试");
            }
        };

    }
}
